package com.project.service.impl;

import java.util.List;
import java.util.Map;

import com.project.entity.News;
import com.project.entity.NewsExample;
import com.project.mapper.NewsMapper;
import com.project.service.NewsManage;

public class NewsManagerService implements NewsManage {
	private NewsMapper newsMapper;
	

	public NewsMapper getNewsMapper() {
		return newsMapper;
	}

	public void setNewsMapper(NewsMapper newsMapper) {
		this.newsMapper = newsMapper;
	}

	
	
	public void deleteById(Integer id) {
		this.newsMapper.deleteByPrimaryKey(id);
	}

	public List<News> findByAuther(String autherName) {
		NewsExample example = new NewsExample();
		example.or().andAuthorEqualTo(autherName);
		return this.newsMapper.selectByExample(example);
	}

	public List<News> getAllNews(Map<String,String> map) {
		// TODO Auto-generated method stub
		return this.newsMapper.getAllNews(map);
	}

	public News getNewsById(Integer id) {
		return this.newsMapper.selectByPrimaryKey(id);
	}

	public void insertNews(News news) {
		this.newsMapper.insert(news);

	}

	public void updateNews(News news) {
		newsMapper.updateByPrimaryKeySelective(news);
	}

	public int totalCount(Map<String,String> map) {
		// TODO Auto-generated method stub
		return this.newsMapper.countAllNews(map);
	}

}
